package org.chench.extra.logsift.vo;

import org.chench.extra.logsift.enums.ResultCode;

/**
 * 返回的json数据格式封装
 * @author chench
 * @date 2025.05.17
 */
public class ResultVO {
    /** 业务状态码，详见{@link ResultCode} */
    private int code = 0;
    /** 业务状态消息 */
    private String message = "";
    /** 业务数据 */
    private Object data = null;

    public static ResultVO build() {
        ResultVO vo = new ResultVO();
        return vo;
    }

    public static ResultVO buildError() {
        return build()
                .setCode(ResultCode.INTERNAL_SERVER_ERROR.getCode())
                .setMessage(ResultCode.INTERNAL_SERVER_ERROR.getMessage());
    }

    public int getCode() {
        return code;
    }

    public ResultVO setCode(int code) {
        this.code = code;
        return this;
    }

    public String getMessage() {
        return message;
    }

    public ResultVO setMessage(String message) {
        this.message = message;
        return this;
    }

    public Object getData() {
        return data;
    }

    public ResultVO setData(Object data) {
        this.data = data;
        return this;
    }

    private ResultVO() {
        this(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(), null);
    }

    private ResultVO(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
}
